const moment = require('moment')                    //处理时间
const { debug } = require('../config/app')
module.exports = (req, res, next) => {
  if (req.url == "/favicon.ico") return false
  const fullURL = req.protocol + '://' + req.get('host') + req.path
  switch (req.method) {
    case 'GET':
      debug && console.log(`${req.method} -- ${fullURL} -- ${JSON.stringify(req.query)} -- ${moment().format('YYYY-MM-DD HH:mm:ss')}`)
      break
    case 'POST':
      debug && console.log(`${req.method} -- ${fullURL} -- ${JSON.stringify(req.body)} -- ${moment().format('YYYY-MM-DD HH:mm:ss')}`)
      break
  }
  next()
}
